/* 
 * File:   Glyphs.cpp
 * Author: cjjonker
 * 
 * Created on 20 december 2012, 16:06
 */

#include "Glyphs.h"
#include "GL/glut.h"


Glyphs::Glyphs()

{
    d_uses_vector_dataset = true;
    d_name = "Vector field visualization";
    d_vector_dataset_names = {"Fluid Flow", "Force Field"};
}

void Glyphs::draw(int winW, int winH)
{
    
    int i, j, idx; 
    const int DIM = d_simulation->getDim();

    fftw_real  wn = (fftw_real)winW / (fftw_real)(DIM + 1);   // Grid cell width
    fftw_real  hn = (fftw_real)winH / (fftw_real)(DIM + 1);  // Grid cell heigh

    setColormapMinMax();

    double gx,gy;
    Vector2f v;

    for (i = 0; i < DIM; i++)
    {
        for (j = 0; j < DIM; j++)
        {
            idx = (j * DIM) + i;
            gx = wn + (fftw_real)i * wn;
            gy = hn + (fftw_real)j * hn;

            v = d_vector_dataset->getData(idx);

            setGLColor(idx);
            glBegin(GL_LINES);
                glVertex2f(gx,gy);
                glVertex2f(gx+1000*v.x, gy+1000*v.y);
            glEnd();
        }

    }
   
    
    /*
    else if (d_glyphtype == Triangle)
    {
        float angle = rad2deg(atan2(v.x, v.y));
        //float size = v.length()*scale;
        
        glPushMatrix();
        glTranslatef(gx,gy,0.0);
        glRotatef(angle, 0.0, 0.0, 1.0);
        glScalef(scale,scale,0.0);
        
        glBegin(GL_TRIANGLES);
            glVertex2f(-1.0, 0.0);
            glVertex2f(1.0, 0.0);
            glVertex2f(0.0, 3.0);
        glEnd();
        glPopMatrix();
    }*/
}

